package com.honghu.villagepost.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.honghu.villagepost.R
import com.honghu.villagepost.entity.Logistics
import com.honghu.villagepost.entity.OrderState
import com.honghu.villagepost.util.CopyUtil

/**
 * @author: mqwang
 * @create: 2/25/21 7:09 AM
 * @Description:
 */
class OrderLogisticsAdapter : BaseQuickAdapter<Logistics, BaseViewHolder>(R.layout.adapter_order_logistics) {
    override fun convert(helper: BaseViewHolder, item: Logistics) {

        helper.setText(R.id.tv_order_no, "订单号：" + item.logisticsNo)

        helper.getView<TextView>(R.id.tv_order_no).setOnClickListener {
            CopyUtil.ClipData(mContext, item!!.logisticsNo)
        }
        helper.setText(R.id.tv_send_name, item.senderName)
        helper.setText(R.id.tv_send_addr, item.senderCity)
        helper.setText(R.id.tv_receiver_name, item.receiverName)
        helper.setText(R.id.tv_receiver_addr, item.receiverCity)

        if (item.state == OrderState.WAIT_PICK) {
            helper.setText(R.id.tv_status, "待揽件")
        } else if (item.state == OrderState.PICK) {
            helper.setText(R.id.tv_status, "已取件")
        } else if (item.state == OrderState.WAIT_TRANSPOST) {
            helper.setText(R.id.tv_status, "待运输")
        } else if (item.state == OrderState.TRANSPOSTING) {
            helper.setText(R.id.tv_status, "运输中")
        } else if (item.state == OrderState.ARRIVED) {
            helper.setText(R.id.tv_status, "到达")
        } else if (item.state == OrderState.WAIT_DELIVERY) {
            helper.setText(R.id.tv_status, "待派送")
        } else if (item.state == OrderState.DELIVERYING) {
            helper.setText(R.id.tv_status, "派送中")
        } else if (item.state == OrderState.SIGNED) {
            helper.setText(R.id.tv_status, "已签收")
        } else if (item.state == OrderState.CANCEL) {
            helper.setText(R.id.tv_status, "已取消")
        }
    }
}